package com.haha;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

import static com.haha.ByteBufferUtil.debugAll;

public class TestByteBufferScattering {
    public static void main(String[] args) {
        try (FileChannel channel=new RandomAccessFile("E:\\gulimail\\nettystudy\\data.txt","r").getChannel()){
            ByteBuffer buffer = ByteBuffer.allocate(3);
            ByteBuffer buffer1 = ByteBuffer.allocate(3);
            ByteBuffer buffer2 = ByteBuffer.allocate(5);
            channel.read(buffer);
            channel.read(buffer1);
            channel.read(buffer2);
            buffer.flip();
            buffer1.flip();
            buffer2.flip();
            debugAll(buffer);
            debugAll(buffer1);
            debugAll(buffer2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
